#include <stdio.h>
void switchnum(short int nbs[40][40], short int nbslen[40], short int n);
short int include(short int a, short int b, short int nbslen[40], short int nbs[40][40]);
int main()
{
    short int n, ilen, isinclude;
    long long int tmp;
    short int nbstmp[40][40] = {0}, nbs[40][40] = {0}, nbslen[40] = {0};

    scanf("%hd", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &tmp);
        for (ilen = 0; tmp > 0; ilen++, tmp /= 10)
        {
            nbstmp[i][ilen] = tmp % 10;
        }
        nbslen[i] = ilen;

        for (int j = 0; j < ilen; j++)
        {
            nbs[i][j] = nbstmp[i][ilen - 1 - j];
        }
        getchar();
    }
    switchnum(nbs, nbslen, n);
    _Bool haveinclude = 1;
    while (haveinclude)
    {
        haveinclude = 0;
        for (int i = 0; i < n - 1; i++)
        {
            isinclude = include(i, i + 1, nbslen, nbs);
            if (isinclude && isinclude < nbs[i][0])
            {
                haveinclude = 1;
                for (int c = 0; c < 40; c++)
                {
                    tmp = nbs[i][c];
                    nbs[i][c] = nbs[i + 1][c];
                    nbs[i + 1][c] = tmp;
                }
                tmp = nbslen[i];
                nbslen[i] = nbslen[i + 1];
                nbslen[i + 1] = tmp;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < nbslen[i]; j++)
        {
            printf("%hd", nbs[i][j]);
        }
    }
}
short int include(short int a, short int b, short int nbslen[40], short int nbs[40][40])
{
    int i;
    for (i = 0; i < nbslen[b]; i++)
    {
        if (nbs[a][i] != nbs[b][i])
        {
            return 0;
        }
    }
    return nbs[a][nbslen[b]];
}
void switchnum(short int nbs[40][40], short int nbslen[40], short int n)
{
    short int tmp;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = 0; k < 40; k++)
            {
                if (nbs[i][k] < nbs[j][k])
                {

                    for (int c = 0; c < nbslen[i] || c < nbslen[j]; c++)
                    {
                        tmp = nbs[i][c];
                        nbs[i][c] = nbs[j][c];
                        nbs[j][c] = tmp;
                    }
                    tmp = nbslen[i];
                    nbslen[i] = nbslen[j];
                    nbslen[j] = tmp;
                    break;
                }
                else if (nbs[i][k] > nbs[j][k])
                {
                    break;
                }
            }
        }
    }
}